package cn.edu.sdju.fengguoyu;


import cn.edu.sdju.fengguoyu.RegisterServer.RegisterServer;
import cn.edu.sdju.fengguoyu.RegisterServer.RegisterService;
import cn.edu.sdju.fengguoyu.annotation.GrpcService;
import com.google.common.util.concurrent.ServiceManager;
import io.grpc.Server;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableScheduling;

import java.io.IOException;
import java.util.Map;
import java.util.Objects;

@SpringBootApplication
@EnableScheduling
public class AhoEdgeRegisterServer {

    public static void main(String[] args) throws IOException, InterruptedException {
        ConfigurableApplicationContext configurableApplicationContext =
                SpringApplication.run(AhoEdgeRegisterServer.class, args);
        Map<String, Object> grpcServiceBeanMap = configurableApplicationContext.getBeansWithAnnotation(GrpcService.class);
        RegisterServer registerServer = configurableApplicationContext.getBean(RegisterServer.class);
        registerServer.loadService(grpcServiceBeanMap);
    }

}
